#include <stdio.h>  
#include <string.h>  
char graph[1005][1005];  
  
int main() {  
    char num;  
    int row;  
    if (scanf("%c%d", &num, &row));   
    for (int i = 0; i < row; i++)  
        for (int j = 0; j < row; j++)  
            graph[i][j] = ' ';  
    for (int i = 0; i < row; i++) {  
        graph[0][i] = num;  
        num++;  
        if (num > '9')  
            num = '0';  
    }  
    for (int i = row - 1; i > 0; i--) {  
        graph[row - i][i - 1] = num;  
        graph[row - i][i] = '\0';  
        num++;  
        if (num > '9')  
            num = '0';  
    }  
    for (int i = row - 2; i > 0; i--) {  
        graph[i][0] = num;  
        num++;  
        if (num > '9')  
            num = '0';  
    }  
    for (int i = 0; i < row; i++) {  
        printf("%s\n", graph[i]);  
    }  
    return 0;  
}  